package as2.model.pojo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "users")
public class User {
	@Id
	@Column(name = "user_id")
	String userId;

	@Column(name = "password")
	String password;

	@Enumerated(EnumType.STRING)
	@Column(name = "role")
	Role role;

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "user")
	Set<Order> orders = new HashSet<Order>();

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRole() {
		return role.toString();
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Set<Order> getOrders() {
		return orders;
	}

	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}

	public String toString() {
		return "name:" + userId + " role:" + role + " orders:" + orders;
	}
}
